package com.dco.dcowebhook.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.util.List;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class WebhookPayload {

    private Repository repository;
    private List<Commit> commits;
    private Pusher pusher;
    private String ref;
    private String before;
    private String after;

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Repository {
        private String name;
        private Owner owner;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Owner {
        private String name;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Commit {
        private String id;
        private String message;
        private Author author;
        private String url;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Author {
        private String name;
        private String email; // 根据需要添加更多字段
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Pusher {
        private String name;
        private String email; // 添加 email 字段
    }

    @Data
    public static class InvalidCommit {
        private String sha;
        private String author;
        private String message;
        private String url;

        public InvalidCommit(String sha, String author, String message, String url) {
            this.sha = sha;
            this.author = author;
            this.message = message;
            this.url = url;
        }
    }
}
